﻿using System.Collections.Generic;

namespace Lr.Core
{
    /// <summary>
    /// Provides extension methods to interact with <see cref="IRangeCycler"/> objects.
    /// </summary>
    public static class IRangeCyclerExtensions
    {
        /// <summary>
        /// Endlessly lists all values of an <see cref="IRangeCycler"/> of <see cref="int"/> in an <see cref="IEnumerable"/>.
        /// </summary>
        /// <returns>An endless <see cref="IEnumerable"/> of <see cref="int"> containing all elements within this specified range.</returns>
        public static IEnumerable<int> AsEnumerable(this IRangeCycler<int> rangeCycler)
        {
            while (true) {
                yield return rangeCycler.Next();
            }
        }
    }
}
